package com.nf.db.handler;

import com.nf.db.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import static com.nf.db.RowProcessor.DEFAULT_ROWPROCESSOR;

public class MapHandler implements ResultSetHandler<Map<String, Object>> {
    @Override
    public Map<String, Object> handle(ResultSet rs) throws SQLException {
        return rs.next() ? DEFAULT_ROWPROCESSOR.toMap(rs) : new HashMap<>();
    }
}
